<?php
namespace Admin\Controller;
class UseronlineController extends AdminController {
	public function index() {
		$this->display();
	}
	public function view() {
		//Load('extend');
		$n =D("User");
		import("ORG.Util.Page"); //导入分页类
		$page=$_POST["page"];
		$rows=$_POST["rows"];
		$sort=$_POST["sort"]?$_POST["sort"]:'id';
		$order=$_POST["order"]?$_POST["order"]:'desc';
		if($sort=='part'){
			$sort='partid';
		}
		$condition['update_time']=array("egt",date("Y-m-d H:i:s",time()-(31*60))); 
		//dump($order);
		if($_POST["account"]!=null&&$_POST["account"]!=""){
			$condition['account']=array('like','%'.$_POST["account"].'%');
		}
		if(I("partid")!=null&&I("partid")!=""){
			$condition['partid']=I("partid");
		}
		if($_POST["createdatetimeStart"]!=null&&$_POST["createdatetimeStart"]!=""){
			$condition['create_time']=array('between',$_POST["createdatetimeStart"],$_POST["createdatetimeEnd"]);
		}
		if($_POST["modifydatetimeStart"]!=null&&$_POST["modifydatetimeStart"]!=""){
			$condition['update_time']=array('between',$_POST["modifydatetimeStart"],$_POST["modifydatetimeEnd"]);
		}
		$count = $n->where($condition)->count(); //计算总数
		//$p = new Page($count,$rows);order($sort+','+$order)->	
		$list = $n->relation(true)->where($condition)->page($page,$rows)->order(array($sort=>$order))->select();
		foreach ($list as $key => $value) {
			$list[$key]['partpid']=$value['part']['pid'];		
		}
		//dump($n->getLastSql());
		$list=json_encode($list);
        $result = '{"status":1,"msg":"成功啦","total":' . $count . ',"rows":' . $list . '}';
		echo ($result); //输出json数据 
	}
}
?>